package com.sherlockHolmes.init.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sherlockHolmes.init.entity.dao.Permissioins;
import com.sherlockHolmes.init.entity.dao.RolePerm;
import com.sherlockHolmes.init.entity.dao.UserInfo;
import com.sherlockHolmes.init.entity.dao.UserRole;
import com.sherlockHolmes.init.service.PermissioinsService;
import com.sherlockHolmes.init.mapper.PermissioinsMapper;
import com.sherlockHolmes.init.service.RolePermService;
import com.sherlockHolmes.init.service.UserRoleService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author 四月一日 君寻
* @description 针对表【permissioins(权限配置)】的数据库操作Service实现
* @createDate 2024-03-25 16:49:10
*/
@Service
public class PermissioinsServiceImpl extends ServiceImpl<PermissioinsMapper, Permissioins>
    implements PermissioinsService{
    @Resource
    private UserRoleService userRoleService;
    @Resource
    private PermissioinsMapper permissioinsMapper;
    @Resource
    private RolePermService rolePermService;
    @Override
    public List<Permissioins> getPermissions(UserInfo member) {
        List<UserRole> role = userRoleService.getRole(member.getId());//获取角色列表
        List<Integer> perMissionsList = rolePermService.getPerMissionsList(role);//获取角色权限列表
        List<Permissioins> list = new LambdaQueryChainWrapper<Permissioins>(permissioinsMapper)
                .in(Permissioins::getId, perMissionsList)
                .list();
        return list;
    }
}




